/**
   \file      Makros.hpp
   \brief     Makro definitions for several the log messages.
   \author    Marco Siciliano

   LibLog implementation.
 
   A library to log into several devices.
   Copyright (C) Marco Siciliano 2002 [marco@siciliano.de]

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#include <sys/time.h>
#include <sstream>
#include "Log.hpp"


#define STREAMHANDLING(msg)                                       \
    std::stringstream MsgStream;                                  \
    MsgStream << msg;                                             \
    const std::string message(MsgStream.str());                   \
                                                                  \
    std::stringstream LineStream;                                 \
    LineStream << __LINE__;                                       \
    const std::string line(LineStream.str());                     \


#define LOG_DEBUG(msg)                                            \
{                                                                 \
    STREAMHANDLING(msg);                                          \
    CLog::instance()->logDebug(__FILE__, line, message);          \
} 

#define LOG_MESSAGE(msg)                                          \
{                                                                 \
    STREAMHANDLING(msg);                                          \
    CLog::instance()->logMessage  (__FILE__, line, message);      \
}                                                                 

#define LOG_ERROR(msg)                                            \
{                                                                 \
    STREAMHANDLING(msg);                                          \
    CLog::instance()->logError  (__FILE__, line, message);        \
}                                                                 

#define LOG_FATAL(msg)                                            \
{                                                                 \
    STREAMHANDLING(msg);                                          \
    CLog::instance()->logFatal  (__FILE__, line, message);        \
}                                                                 

#define LOG_ENTER_FUNCTION(funcname)                              \
{                                                                 \
    CLog::instance()->indent();                                   \
    LOG_MESSAGE(funcname)                                         \
}

#define LOG_LEAVE_FUNCTION()                                      \
{                                                                 \
    CLog::instance()->unindent();                                 \
}



